﻿////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Controla los botones SIGUIENTE y ANTERIOR para cambiar a la escena correspondiente
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

using UnityEngine;
using System.Collections;

public class GUISceneButtons : MonoBehaviour
{
	public GUISkin mSkin;
	public string sTitle;

	public string sSceneNext;
	public string sScenePrev;
	public bool bSceneNext;
	public bool bScenePrev;

	Rect rectLabel;
	Rect rectButtonNext;
	Rect rectButtonPrev;

	float ratio;
	int fontSize;
	float labelH;

	public bool bFinal=false;

	GUISelectObject guiSelectObject;
	CameraController cameraController;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	void Awake()
	{
		cameraController = GetComponent<CameraController>();
		guiSelectObject = GetComponent<GUISelectObject>();
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	void Start()
	{
		ratio = Screen.width/480.0f;
		fontSize = (int)(30*ratio);
		mSkin.GetStyle("styleTitle").fontSize = fontSize;
		mSkin.GetStyle("styleTitleShadow").fontSize = fontSize;
		labelH = Screen.height*0.1f;
		rectLabel = new Rect(0, 0, Screen.width, labelH);

		rectButtonNext = new Rect(Screen.width-ButtonProps.buttonSize-15, Screen.height-ButtonProps.buttonSize-ButtonProps.buttonMargin, ButtonProps.buttonSize, ButtonProps.buttonSize);
		rectButtonPrev = new Rect(ButtonProps.buttonMargin, Screen.height-ButtonProps.buttonSize-ButtonProps.buttonMargin, ButtonProps.buttonSize, ButtonProps.buttonSize);
	}

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	void OnGUI()
	{
		GUI.skin = mSkin;

		GUI.Label(rectLabel, sTitle, "styleTitleShadow");
		GUI.Label(rectLabel, sTitle, "styleTitle");

		if(!bFinal){
			if(bSceneNext){
				if(guiSelectObject.objectsArray[cameraController.currentIndex].name!="beany"){
					if(GUI.Button(rectButtonNext, "", "next")){
						Application.LoadLevel(sSceneNext);
					}
				}
			}
		}

		if(bScenePrev){
			if(GUI.Button(rectButtonPrev, "", "prev")){
				Application.LoadLevel(sScenePrev);
			}
		}
	}
}





